//-----------------------------------------------------------------------------
//
// @file	Scene.h
// @brief	File with all scene data
// @author	Vinod Melapudi
// @date	20Feb2010
//
//-----------------------------------------------------------------------------

#ifndef _SCENE_H
#define _SCENE_H

#include "Vector.h"
#include "Camera.h"

class Renderer;

struct SceneText;

//
// @class	Scene
// @brief	Scene functionalities
//
class Scene
{
public:
	Scene()		{}
	~Scene()	{}

	virtual bool Init();
	virtual void Update();
	virtual void Render( Renderer* renderer );
	virtual void RenderHUD( Renderer* renderer, float normalized_x_pos, float normalized_y_pos, std::vector<std::string> text );
	virtual void RenderText( Renderer* renderer, std::vector<SceneText> scene_texts );
	virtual void RenderText( Renderer* renderer, const SceneText& scene_text );
	virtual bool HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam );
	virtual void UnInit();

	// Set/Get screen dimension
	void SetScreenDimension( int w, int h );
	void GetScreenDimension( int &w, int &h );

	// Screen to world / world to screen pos
	void	ScreenToWorld( Vector2 spos, Vector3& near_wpos, Vector3& far_wpos ) const;
	bool	WorldToScreen( Vector3 wpos, Vector2 &spos ) const;

protected:	

	// Helper functions -----------------------------------------------
	void		DrawAxis( Vector3 position=Vector3(0.f,0.f,0.f), float size=1.0f ) const;

	Vector2		GetMousePos( LPARAM lParam ) const;

	// Vertex buffer -----------------------------------------------
#ifdef VBO_SUPPORT
	bool InitVBO();
	void UnInitVBO();
#endif

protected:

	// Rendering stuff -----------------------------------------------

#ifdef VBO_SUPPORT
	unsigned int		m_vertex_VBO;					// VBO ids
	unsigned int		m_normal_VBO;
	unsigned int		m_texture_VBO;
	unsigned int		m_color_VBO;
#endif

#ifdef SHADER_SUPPORT
	unsigned int		m_vertex_shader;				// Shaders
	unsigned int		m_fragment_shader;
	unsigned int		m_shader_program;
#endif

	// Screen size
	int m_screen_width;
	int m_screen_height;


	// Camera
	Camera		m_camera;

	bool		m_cameraEnableNavigation;

	// Mouse
	Vector2		m_mouse_pos;
	Vector2		m_mouse_last_pos;

	// HUD
	bool		m_show_HUD;
	float		m_FPS;
};



// Scene text representation
struct SceneText
{
	std::string text;
	float normalized_x_pos;		// Between -1 & 1
	float normalized_y_pos;		// Between -1 & 1

	SceneText( const std::string& t, float x, float y )		
	{
		text = t;
		normalized_x_pos = ( x >= -1.f && x <= 1.f ) ? x : 0.f;
		normalized_y_pos = ( y >= -1.f && y <= 1.f ) ? y : 0.f;
	}
};



#endif

